// 初始化判断当前是否登录 引入其他reqToken.js 公共Token
$(function () {
    if (token == null) {
        layer.msg('未登录', {
            icon: 0,
            time: 1200,
            end: function () {
                alert("index.js的toekn为NULL");
                location.href = '/html/admin/login.html';
            }
        })
        return;
    }
    $.ajax({
        type: 'get',
        url: requestURL+prefix+userService+'/admin/loginAdmin',
        headers: {"Authorization":authToken},
        success: function (res) {
            if (res.status == 200) {
                //存储管理员Id、name，用户数据回显查询
                sessionStorage.setItem("aId", res.object.id);
                sessionStorage.setItem("name", res.object.name);
                sessionStorage.setItem("loginLogId", res.object.loginLogId);
                // 将登录用户名回显
                let name = res.object.name;
                $("#admin").html(name);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            var state = XMLHttpRequest.status;
            if (state == 403) {
                layui.layer.msg('权限不足，请联系超级管理员！', {icon: 0, time: 1200});
                return false;
            }
            layui.layer.msg('请求接口异常！', {icon: 0, time: 1200});
            return false;
        }

    });
    return false;
});
